﻿/*
 * History:
 * ----------------
 * review by   : Yaser
 * review date : JUL-21-09
 * ----------------
 * by : Yaser
 * date : Feb 26th 11
 * ----------------
 */
using System;

namespace ERP.Business.DataTypes.Users.Credentials
{
    /// <summary>
    /// Permission class
    /// </summary>
    [System.Runtime.Serialization.DataContract]
    [Serializable]
    [System.Runtime.Serialization.KnownType(typeof(Permission))]
    public class Permission : ERP.Business.DataTypes.BaseTypes.BaseType
    {
        #region Properties

        /// <summary>
        /// Gets or sets the module ID.
        /// </summary>
        /// <value>The module ID.</value>
        [System.Runtime.Serialization.DataMember]
        public string ModuleID
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets a value indicating whether [allow view].
        /// </summary>
        /// <value><c>true</c> if [allow view]; otherwise, <c>false</c>.</value>
        [System.Runtime.Serialization.DataMember]
        public bool AllowView
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets a value indicating whether [allow modify].
        /// </summary>
        /// <value><c>true</c> if [allow modify]; otherwise, <c>false</c>.</value>
        [System.Runtime.Serialization.DataMember]
        public bool AllowModify
        {
            get;
            set;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of <paramref name="x"/> and <paramref name="y"/>, as shown in the following table.Value Meaning Less than zero <paramref name="x"/> is less than <paramref name="y"/>. Zero <paramref name="x"/> equals <paramref name="y"/>. Greater than zero <paramref name="x"/> is greater than <paramref name="y"/>.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">Neither <paramref name="x"/> nor <paramref name="y"/> implements the <see cref="T:System.IComparable"/> interface.-or- <paramref name="x"/> and <paramref name="y"/> are of different types and neither one can handle comparisons with the other. </exception>
        public override int Compare(object x, object y)
        {
            if (ERP.Framework.Components.Utilities.ComparingHelper.ComapringManager.CompareTypes(x, y))
                return ((Permission)x).ModuleID.CompareTo(((Permission)y).ModuleID);
            return -1;
        }

        #endregion
    }
}
